#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include "rngs.h"



#define DEBUG 0
#define NOISY_TEST 1

int adventurerCard(int *takenTreasure, struct gameState *state, int *cardDrawn, int *currentPlayer, int *temporaryHand, int *z);


int random_number(int mininumNumber, int maximumNumber)
{
    int result=0,lowNumer=0,highNumber=0;
    if(mininumNumber<maximumNumber)
    {
        lowNumer=mininumNumber;
        highNumber=maximumNumber+1;
    }
    else
    {
        lowNumer=maximumNumber+1;
        highNumber=mininumNumber;
    }
    srand(time(NULL));
    result = (rand()%(highNumber-lowNumer))+lowNumer;
    return result;
}

int main(int argc, char const *argv[])
{
    
    struct gameState game;
    
    int i, j;
    int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
    
    int takenTreasure;
    int currentplayer;
    int temporaryHand[MAX_HAND];
    int z;
    int cardDrawn;
    int myCard;
    int temporaryCoins;
    
    
    for (i = 0; i < random_number(0, 100); i ++)
    {
        initializeGame(random_number(2,4), k, random_number(1, 9), &game);
        
        currentplayer = game.whoseTurn;
        
        // Test 1000x
        for (j = 0; j < 10000; j++)
        {
            takenTreasure = random_number(0, 10);
            temporaryCoins = game.coins;
            
            myCard = adventurerCard(&takenTreasure, &game, &cardDrawn, &currentplayer, temporaryHand, &z);
            if (temporaryCoins > game.coins)
            {
                printf("Error: TemporaryCoins [%d] game.coins[%d]\n", temporaryCoins, game.coins);
            }
        }
    }
    
    return 0;
}